package com.yunxiangyue.room_login_info

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase


@Database(version = 1, entities = [LogInfo::class])
abstract class LogDataBase :RoomDatabase(){
    abstract fun logDao():LogDao



    //获取数据库的单例对象
    companion object {
        private var instance:LogDataBase? = null

        @Synchronized
        fun getLogDatabase(context: Context):LogDataBase{
            instance?.let {
                return it
            }
            return Room.databaseBuilder(context.applicationContext,LogDataBase::class.java,"log_databse").allowMainThreadQueries()
                .build().apply {
                    instance = this
                }
        }
    }

    }